type
  Person = ref object of RootObj
    name: string
    age: int

  Student = ref object of Person
    grade: int

var s1=Student(name:"damao", age:20, grade:100)
echo s1[]
echo s1 of Student
echo s1 of Person

var p1:Person=s1
if p1 of Student:
  echo Student(p1).grade

var p2:Person=s1
if p2 of Student:
  echo cast[Student](p2).grade
